#! /bin/bash
set -ex
ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile $ORDERER_CA

peer channel join -b mychannel.block

peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile $ORDERER_CA

# CORE_PEER_ADDRESS=peer0.org1.example.com:7051
# CORE_PEER_ADDRESS=peer1.org1.example.com:8051
# peer channel join -b mychannel.block

# CORE_PEER_ADDRESS=peer3.org1.example.com:7051
# peer channel join -b mychannel.block
# CORE_PEER_ADDRESS=peer4.org1.example.com:7051
# peer channel join -b mychannel.block

CORE_PEER_LOCALMSPID="Org2MSP" 
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp 
CORE_PEER_ADDRESS=peer0.org2.example.com:9051
peer channel join -b mychannel.block
peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile $ORDERER_CA


# CORE_PEER_ADDRESS=peer1.org2.example.com:10051
# peer channel join -b mychannel.block
# CORE_PEER_ADDRESS=peer2.org2.example.com:8051
# peer channel join -b mychannel.block
# CORE_PEER_ADDRESS=peer3.org2.example.com:8051
# peer channel join -b mychannel.block
# CORE_PEER_ADDRESS=peer4.org2.example.com:8051
# peer channel join -b mychannel.block
